#pragma once
#include <map>
#include <array>
#include <utility>
#include <opencv2/opencv.hpp>
#include <experimental/filesystem>
#include <fstream>
#include <iomanip>
#include "utils.h"


class MotDrawer {
public:
    explicit MotDrawer();

    ~MotDrawer();

    void update(const std::vector<BBox> &trks,
                uint32_t frame, const cv::Mat &image);

    void DrawTrajectories(cv::Mat& ori_img, vector<BBox>& trackResults, bool isDrawTrajectory);

private:

    void draw_trajectory(cv::Mat &img, const std::map<int, cv::Rect2f> &traj,
        const cv::Scalar &color);

    struct Target {
        std::map<int, cv::Rect2f> trajectories;
        std::map<int, cv::Mat> snapshots;
        int last_snap = 0;
    };

    const std::map<int, Target> &get() const { return targets; }


    void record(uint32_t remain);

    cv::Rect2f pad_rect(cv::Rect2f rect, float padding);
    cv::Rect2f normalize_rect(cv::Rect rect, float w, float h);
    cv::Rect unnormalize_rect(cv::Rect2f rect, float w, float h);
    static constexpr float padding = 0.1f;

    
    std::map<int, Target> targets;
};